package ryulib;

import java.util.HashMap;

public class ValueList extends HashMap<String, String> {

	private static final long serialVersionUID = 1065478499595139080L;
	
	public void put(String AKey, int AValue) {
		put(AKey, Integer.toString(AValue));
	}
	
	public int getInt(String AKey) {
		return Integer.parseInt(get(AKey));
	}
	
	public void addText(String text, String seperator) {
		String[] array = text.split(seperator);
		
		String key;
		String value = "";
		
		for (String item : array) {
			String[] line = item.split("=");
			
			key = line[0];
			
			if (line.length > 1) value = line[1];
			else value = "";
			
			put(key, value);
		}
	}
	
	public String getText(String seperator) {
		String result = "";
		for (String key : keySet()){
			result = result + String.format("%s=%s%s", key, get(key), seperator); 
        }
		
		return result;
	}
	
	public void setText(String text, String seperator) {
		clear();
		
		String[] array = text.split(seperator);
		
		String key;
		String value = "";
		
		for (String item : array) {
			String[] line = item.split("=");
			
			key = line[0];
			
			if (line.length > 1) value = line[1];
			else value = "";
			
			put(key, value);
		}
	}
	
}